#/bin/sh

TOP_PATH = ./

SRCPTH = $(TOP_PATH)
INPTH  = $(TOP_PATH)

CXX = g++
#CXXFLAGS = 

TARG = lmgb28
INLPTH =  -ansi -Wall -g -O3

DIRS  = $(SRCPTH) common  lmSip  lmNet lmSBuff lmAvStream lmAvStream/lmps  lmAvStream/lmrtp lmAvStream/lmAvComm  
LPTH := -L$(TOP_PATH)lmSip/thirLib/libosip2-5.0.0/lib -losip2 -losipparser2 \
		-L$(TOP_PATH)lmSip/thirLib/libexosip2-5.0.0/lib -leXosip2 \
		-lpthread \
		-Wl,-rpath=$(TOP_PATH)lmSip/thirLib/libosip2-5.0.0/lib \
		-Wl,-rpath=$(TOP_PATH)lmSip/thirLib/libexosip2-5.0.0/lib 

INLPTH  += $(SRCPTH) -Icommon -IlmAvStream -IlmSip -IlmNet -IlmSBuff \
					 -IlmSip/thirLib/libosip2-5.0.0/include \
					 -IlmSip/thirLib/libexosip2-5.0.0/include \
					 -IlmAvStream/lmps \
					 -IlmAvStream/lmrtp \
					 -IlmAvStream/lmAvComm 
				  
FILES = $(foreach dir, $(DIRS),  $(wildcard $(dir)/*.cpp))
OBJS  = $(patsubst %.cpp, %.o, $(FILES))


.PHONY:$(TARG)

$(TARG):$(OBJS)
	$(CXX) -o $(TARG)  $^ $(LPTH) 
	
.cpp.o:
	$(CXX) -c $(INLPTH) $<  -o $(TOP_PATH)/$@
	
clean:
	rm -f *.o *~ *.orig *.tmp
	rm -f $(TARG)
	rm -fr $(OBJS)
